<!DOCTYPE html>
<html lang="en">
<head>

    <title></title>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="/layui-2.4.2/src/css/layui.css">
    <script type="text/javascript" src="/jquery/jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="/layui-2.4.2/src/layui.js"></script>
    <script type="text/javascript" src="/wangEditor.min.js"></script>
<body>
    <div>
        <div class="layui-row">
            <table id="calculation_view" lay-filter="calculation_view_filter">

            </table>
        </div>
    </div>

<script type="text/javascript">
    layui.use('form', function () {
        var form = layui.form;

        //自定义表单验证（金额）
        form.verify({
            validateMoney: [
                /^\d+(\.\d{1,2})?$/  //正则表达式 非负浮点数,可保留一位，二位小数
                ,'金额只能为正数'  //提示信息
            ]
        });
        layui.use(['element','table','laytpl'], function(){
        var table=layui.table;
        //商品列表
        table.render({
            elem:'#calculation_view',
            url:'/calculation/list',
            page:true,
            limit:10,
            limits:[10,20,50,100],
            cols:[
                [
                    {field:'level',title:'会员等级'},
                    {field:'honeyValue',title:'付费蜂蜜值',edit:'text'},
                    {field:'rebate',title:'个人付费返利百分比',edit:'text'},
                    {field:'parentFirst',title:'直接上级反蜜糖百分比',edit:'text'},
                    {field:'parentSecond',title:'间接上级反蜜糖百分比',edit:'text'},
                    {field:'valid',title:'蜂蜜有效时间',edit:'text'},
                    {field:'subscriptionRatio',title:'蜂蜜兑换蜜糖比例',edit:'text'},
                    {field:'promotionDiligenceDegree',title:'用户晋升勤劳度',edit:'text'},
                    {field:'transferFeeRate',title:'转账手续费率',edit:'text'},
                    {field:'upgradeAward',title:'个人升级奖励',edit:'text'}
                ]
            ],
            // request:{page:'page',limit:'limit'},
            response:{
                status:'errorCode',
                countName:'total',
                dataName:'data'
            }
        });

        table.on('edit(calculation_view_filter)',function(obj){
           var value=obj.value;
           var data=obj.data;
           // var field=obj.field;
           $.ajax({
               type: 'post',
               dataType:'json',
               contentType:'application/json;charset-UTF-8',
               data: JSON.stringify(obj.data),
               url: '/calculation/update',
               cache: false,
               success: function (data) {
                   if(data.success==true){
                       $(".layui-laypage-btn").click();
                   }else{
                       alert('请检查输入的数据格式是否正确');
                   }

               }
           })
        })
    })
    })
</script>
</body>
</html>